﻿Public Class clsInhSklad
    Inherits clsSklad

#Region "Attributes"
    Private mvarSklad As New Collection(Of clsInhSklad)
    Private mvarPierwiastek As clsPierwiastek
#End Region

#Region "Properties"

    Public Property Sklad() As Collection(Of clsInhSklad)
        Get
            Return mvarSklad
        End Get
        Set(ByVal value As Collection(Of clsInhSklad))
            mvarSklad = value
        End Set
    End Property

    Public Property Pierwiastek() As clsPierwiastek
        Get
            Return mvarPierwiastek
        End Get
        Set(ByVal value As clsPierwiastek)
            mvarPierwiastek = value
        End Set
    End Property

#End Region

#Region "Methods"

    Public Sub New()
        MyBase.New()
    End Sub

    Public Sub New(ByVal ID As Integer, ByVal lvarDbHolder As clsDataBase)

        MyBase.New(ID, lvarDbHolder, VAR_ERROR_HANDLER)
        mvarPierwiastek = New clsPierwiastek(MyBase.PierwiastekId, lvarDbHolder, VAR_ERROR_HANDLER)

    End Sub

    Public Overloads Sub Save(ByVal lvarDbHolder As clsDataBase)
        MyBase.Save(lvarDbHolder, VAR_ERROR_HANDLER)
    End Sub

    Public Overloads Sub Delete(ByVal lvarDbHolder As clsDataBase)

        MyBase.Delete(lvarDbHolder, VAR_ERROR_HANDLER)

    End Sub

    Public Sub PobierzWszystkiePierwiastkiStop(ByVal lvarDbHolder As clsDataBase, ByVal Zapytanie As Integer)

        Dim lvarReader As OdbcDataReader = Nothing
        Dim lvarReturn As DataTable

        If lvarDbHolder.IsOpen Then
            Dim lvarSqlRunner As New clsSqlRunner(lvarDbHolder, "queries_application_oem", "cls_sklad", 2, VAR_ERROR_HANDLER)

            With lvarSqlRunner
                .AddParameter("p_id", Zapytanie.ToString())
                lvarReader = .ExecuteQuery
            End With
            If lvarReader.HasRows Then
                While lvarReader.Read
                    mvarSklad.Add(New clsInhSklad(CInt(IIf(IsDBNull(CInt(lvarReader.Item("id"))), -1, CInt(lvarReader.Item("id")))), lvarDbHolder))
                End While
            End If
        End If

    End Sub


#End Region

End Class
